package com.lhy.service.impl;

import com.lhy.dao.DrugsDao;
import com.lhy.domain.Drugs;
import com.lhy.domain.User;
import com.lhy.service.DrugsService;
import com.lhy.utils.Pagination;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 汪
 */
@Service
public class DrugServiceImpl implements DrugsService {
    @Autowired
    DrugsDao drugsDao;
    @Override
    public List<Drugs> showAllDrugs() {
        return drugsDao.showAllDrugs();
    }

    @Override
    public int addDrugs(Drugs drugs) {
        return drugsDao.addDrugs(drugs);
    }

    @Override
    public int deleteDrugs(int drugsId) {
        return drugsDao.deleteDrugs(drugsId);
    }

    @Override
    public int modifyDrugs(Drugs drugs) {
        return drugsDao.modifyPrice(drugs);
    }

    @Override
    public int modifyNum(Drugs drugs) {
        Integer num = drugsDao.selectByid(drugs.getDrugsId()).getNum();
        Integer new_num=num+drugs.getNum();
        Drugs new_drugs=new Drugs();
        new_drugs.setDrugsId(drugs.getDrugsId());
        new_drugs.setNum(new_num);
        return drugsDao.modifyNum(new_drugs);
    }

    @Override
    public List<Drugs> showSomeDrugs(Drugs drugs) {
        return drugsDao.showSomeDrugs(drugs);
    }

    @Override
    public void updateFilePath(Drugs drugs) {
        drugsDao.fileUpload(drugs);
    }

    @Override
    public List<Drugs>  showSomeDrugs1(Pagination<Drugs> page) {
        return drugsDao.showSomeDrugs1(page);
    }
}
